﻿using System.Collections.Generic;

namespace Chess.Domain
{
	internal class KnightPositionDeterminant : IPositionDeterminant
	{
		/// <summary>
		/// 
		/// </summary>
		/// <param name="position"></param>
		/// <returns></returns>
		public List<Position> AvailablePositions(Position currentPosition)
		{
			List<Position> results = new List<Position>();
			int deltaY = 0;
			int deltaX = 0;
			Position item;

			deltaY = 2;
			deltaX = 1;
			if (currentPosition.CanTranslate(deltaY, deltaX, out item))
			{
				results.Add(item);
			}

			deltaY = 2;
			deltaX = -1;
			if (currentPosition.CanTranslate(deltaY, deltaX, out item))
			{
				results.Add(item);
			}

			deltaY = -2;
			deltaX = 1;
			if (currentPosition.CanTranslate(deltaY, deltaX, out item))
			{
				results.Add(item);
			}

			deltaY = -2;
			deltaX = -1;
			if (currentPosition.CanTranslate(deltaY, deltaX, out item))
			{
				results.Add(item);
			}

			deltaY = 1;
			deltaX = 2;
			if (currentPosition.CanTranslate(deltaY, deltaX, out item))
			{
				results.Add(item);
			}

			deltaY = -1;
			deltaX = 2;
			if (currentPosition.CanTranslate(deltaY, deltaX, out item))
			{
				results.Add(item);
			}

			deltaY = 1;
			deltaX = -2;
			if (currentPosition.CanTranslate(deltaY, deltaX, out item))
			{
				results.Add(item);
			}

			deltaY = -1;
			deltaX = -2;
			if (currentPosition.CanTranslate(deltaY, deltaX, out item))
			{
				results.Add(item);
			}


			return results;
		}
	}
}
